package com.tiheima.config;

import com.tiheima.interceptor.LoginInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list = new ArrayList<>();
        list.add("/login");
        list.add("/register");
        registry.addInterceptor(loginInterceptor)
                // 拦截所有
                .addPathPatterns("/**")
                // 方向登录接口
                // .excludePathPatterns("/login");
                .excludePathPatterns(list);
    }
}
